package com.lch.designpattern.prototype.simple;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: liuchenhui
 * @create: 2019-04-17 22:52
 **/
public class ConcretePrototypeATest {
    public static void main(String[] args) {
        ConcretePrototypeA concretePrototypeA = new ConcretePrototypeA();

        concretePrototypeA.setName("lch");
        concretePrototypeA.setAge("18");
        List hobbies = new ArrayList<String>();

        Client client = new Client();
        ConcretePrototypeA prototypeCopy = (ConcretePrototypeA) client.startClone(concretePrototypeA);
        System.out.println("clone:" + prototypeCopy);

        System.out.println("克隆对象中引用类型地址的值：" + prototypeCopy.getHobbies());
        System.out.println("源对象中的引用类型地址的值：" + concretePrototypeA.getHobbies());
        System.out.println("对象引用对比：" + (concretePrototypeA == prototypeCopy));
        System.out.println("比较引用地址：" + (prototypeCopy.getHobbies() == concretePrototypeA.getHobbies()));
    }
}